﻿using DotNetty.Buffers;
using QQ.Client;
using QQ.Packet.Request.TLV;
using System.Collections.Generic;

namespace QQ.Packet.Request
{
    public class LoginRequest : IRequest
    {
        private readonly QQDeviceConfig config;
        public LoginRequest(QQDeviceConfig config)
        {
            this.config = config;
        }

        public uint uin { get; set; }
        public string password { get; set; }
        private LoginType loginType { get; set; } = LoginType.PASSWORD;
        public uint ssoSequenceId { get; set; }
        public IByteBuffer Serialize() => new wtlogin_login()
        {
            subCommand = 9,
            tlvs = new Dictionary<short, IByteBuffer>()
                {
                    { 0x106, new TLV0x106(config){ uin = uin,password = password,loginType = loginType}.Serialize() },
                    { 0x116, new TLV0x116(config).Serialize() },
                    { 0x100, new TLV0x100(config).Serialize() },
                    { 0x107, new TLV0x107(config).Serialize() },
                    { 0x144, new TLV0x144(config).Serialize() },
                    { 0x145, new TLV0x145(config).Serialize() },
                    /*
                    { 0x18, new TLV0x18(config){ uin = uin }.Serialize() },
                    { 0x1, new TLV0x1(config){ uin = uin}.Serialize() },
                    { 0x147, new TLV0x147(config).Serialize() },
                    { 0x142, new TLV0x142(config).Serialize() },
                    { 0x154, new TLV0x154(config){ ssoSequenceId = ssoSequenceId}.Serialize() },
                    { 0x141, new TLV0x141(config).Serialize() },
                    { 0x8, new TLV0x8().Serialize() },
                    { 0x511, new TLV0x511(config).Serialize() },
                    { 0x187, new TLV0x187(config).Serialize() },
                    { 0x188, new TLV0x188(config).Serialize() },
                    { 0x194, new TLV0x194(config).Serialize() },
                    { 0x191, new TLV0x191(config).Serialize() },
                    { 0x202, new TLV0x202(config).Serialize() },
                    { 0x177, new TLV0x177(config).Serialize() },
                    { 0x516, new TLV0x516(config).Serialize() },
                    { 0x521, new TLV0x521(config).Serialize() },
                    { 0x525, new TLV0x525(config).Serialize() },
                    */
                }
        }.Serialize();
    }
}
